/**
 * @Created by Webstorm
 * @Author: 打字桶
 * @Desc
 */
import Http from "../utils/http";
import Base from "./base";

class Order extends Base {
  static createOrder(service_id, address) {
    return Http.request({
      url: 'v1/order',
      data: {
        service_id,
        address
      },
      method: 'POST'
    })
  }

  static getOrderStatus(role) {
    return Http.request({
      url: `v1/order/count?role=${role}`
    })
  }

  async getMyOrderList(role, status) {
    if (!this.hasMoreData) {
      return this.data
    }
    const orderList = await Http.request({
      url: 'v1/order/my',
      data: {
        page: this.page,
        count: this.count,
        role,
        status
      }
    })
    this.data = this.data.concat(orderList.data)
    this.hasMoreData = this.page !== orderList.last_page
    this.page++
    return this.data
  }
}

export default Order
 